import request from '../utils/request'

// 注册接口
export const userRegisterService = ({ username, password, repassword }) => {
  return request.post('/api/reg', { username, password, repassword })
}

// 登录接口
export const userLoginService = ({ username, password }) => {
  return request.post('/api/login', { username, password })
}

// 用户信息
export const userInfoService = () => {
  return request.get('/my/userinfo')
}

// 更新用户基本资料

export const putUserInfoService = ({ id, nickname, email }) => {
  return request.put('/my/userinfo', { id, nickname, email })
}

// 更换头像
export const userUploadAvatarService = (avatar) => request.patch('/my/update/avatar', { avatar })

// 更换密码
export const userUpdatePassService = ({ old_pwd, new_pwd, re_pwd }) =>
  request.patch('/my/updatepwd', { old_pwd, new_pwd, re_pwd })
